package stream;

import java.util.Optional;

/**
 * @author： pang-yun
 * @date： 2021-10-27 17:52
 * 功能目的 ：用于
 */

public class OptionalTest {
    public static void main(String[] args) {
        //   Optional<Dog> optional = Optional.of(null);

        Optional<Object> empty = Optional.empty();
        System.out.println(empty);
        Optional<Object> o = Optional.ofNullable(null);
        System.out.println(o.isPresent());

        Optional<Object> a = Optional.ofNullable(empty).orElse(Optional.of(new Dog("A", 23)));

        System.out.println(a.orElseGet(() -> {
            if (1 > 0) {
                return new Dog("b", 12);
            } else {
                return new Dog("c", 11);
            }
        }));
    }
}
